import 'package:flutter/material.dart';
import 'package:gsy_flutter_app/common/dao/UserDao.dart';
import 'package:gsy_flutter_app/page/HomePage.dart';
import 'package:gsy_flutter_app/page/LoginPage.dart';

class WelcomePage extends StatelessWidget {
  const WelcomePage({super.key});

  @override
  Widget build(BuildContext context) {
    
    toNext(res) {
      Widget widget;
      if (res!=null && res.result) {
        widget = const HomePage();
      } else {
        widget = const LoginPage();
      }
      Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) {
        return widget;
      }));
    }

    ///两秒后跳转HomePage
    Future.delayed(const Duration(seconds: 2), () {
      UserDao.initUserInfo().then((res) {
        toNext(res);
      });
    });
    return Container(
      color: Colors.white,
      child: const Center(
          child: Image(
        image: AssetImage('static/images/welcome.png'),
      )),
    );
  }
}
